const {
	quickSaveMethod,
	editMethod,
} = require('./api-button-methods-2x');

module.exports = function(apiComp) {
	window.addEventListener('beforeunload', function(e) {
		alert(arguments)
		console.log(e)
		console.log(arguments)
		return 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
			// reqGet('/ult/project/unlock', {
			// 	project_id: projectId,
			// })
	})
	document.onkeydown = function(e) {
		// ctrl键
		let currKey = e.keyCode || e.which || e.charCode;
		let ctrlKey = e.ctrlKey || e.metaKey
		let altKey = e.altKey

		// ctrl+s保存
		if (ctrlKey && currKey == 83) {
			e.preventDefault();
			if (apiComp.store.isLock)
				quickSaveMethod.call(apiComp)
			return false;
		}

		// ctrl+e开始编辑
		if (ctrlKey && currKey == 69) {
			e.preventDefault();
			if (!apiComp.store.isLock)
				editMethod.call(apiComp)
			return false;
		}
	}
}